<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>h5demo测试</title>
    <!-- <script src="./js/vue.js"></script> -->
</head>
<body>
    <div id="app">
        
        <button id="btn0" onclick="anzhuo1()" style="margin:20px 0;">安卓浏览器跳到指定直播页面</button><br>
        <button id="btn1" onclick="anzhuo2()" style="margin:20px 0;">调用android有参参数</button>

        <div id="content"></div>
        <button onclick="login()" style="margin:20px 0;">h5发送消息到ios</button><br>
        <button onclick="ioswindowfn()" style="margin:20px 0;">ios调用h5触发方法</button>
        <div id="ioscontent"></div>
    </div>
    
    <script>
        //! 登录
        function login() {
            var token = "js_tokenString";
            loginSucceed(token);
        }

        //! 登录成功
        function loginSucceed(token) {
            var action = "1828";
            if(appDown() == 'ios'){
                window.webkit.messageHandlers.openiOS.postMessage(action, token);
            }else{
                alert("这里是安卓")
            }
            
        }
        //点击下载按钮判断
        function appDown() {
            var u = navigator.userAgent;
            var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
            var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
            if(isiOS){
                return "ios"
            }else if(isAndroid){
                return "andriod"
            }
        }
        function anzhuo1 (){
            window.location.href = 'youin://live/rtc?liveId='+document.getElementById("content").value;
        }
        function anzhuo2 (){
            android.startRtc(document.getElementById("content").value);
        }
        var content = document.getElementById("content");
        function message(){
            content.innerHTML = "调用了有参的js函数"
        };

        function message2(des){
            content.innerHTML = "调用了"+des;
        };

        var ioscontent = document.getElementById("ioscontent");
        function ioswindowfn(data){
            ioscontent.innerHTML = "（这个不用管）ios调用了并且传参了"+data;
        }
        window.ioswindowfn = ioswindowfn()
    </script>
</body>
</html>
